package qe.spider.vo;

import cn.hutool.core.util.StrUtil;
import lombok.Data;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;

import java.math.BigDecimal;
import java.util.Date;

@Data
@Slf4j
public class GoodStock {
    private String code;
    private String name;
    private String upTime;  //上榜时间
    private String upScore; //上榜价格
    private String upRate;  //上榜涨幅
    private String score;   //当前价格
    private String rate;    //当前涨幅
    private String time;    //当前时间
    private String volume;  //成交额
    private String plate;
    private String zhuBuyZhanBi;
    private String zhuSellZhanBi;
    private String zhuLiBuy;
    private String zhuLiSell;
    private String zhuLiJingE;
    private String zhuLiJingLiang;
    private String shiJiHuanShouLv;
    private String upVolume;  //上榜时的成交额
    private String upZhuBuyZhanBi;
    private String upZhuSellZhanBi;
    private String upZhuLiBuy;
    private String upZhuLiSell;
    private String upZhuLiJingE;
    private String upZhuLiJingLiang;
    private String upShiJiHuanShouLv;

    private String zhangTingJia;

    public String marketCode() {
        if (StrUtil.startWith(code, "60")) return "SH";
        else if (StrUtil.startWith(code, "00")) return "SZ";
        else if (StrUtil.startWith(code, "30")) return "SZ";
        else return "";
    }

    public Boolean isUpLimit(String jiage) {
//        Double upLimit = zhangfu.trim().endsWith("%") ? new BigDecimal(zhangfu.trim().replace("%", "")).doubleValue() : new BigDecimal(zhangfu.trim()).doubleValue();
//        if (code.startsWith("688")) return upLimit >= 19.7 && upLimit <= 20.1;//科创板
//        else if (code.startsWith("30")) return upLimit >= 19.7 && upLimit <= 20.1; //创业板
//        else return upLimit >= 9.7 && upLimit <= 10.2;
        Boolean isZhangTing = new BigDecimal(zhangTingJia).compareTo(new BigDecimal(jiage)) == 0;
//        log.info("{}（{}）当前价：{}，涨停价：{}，是否涨停：{}",code,name, jiage, zhangTingJia, isZhangTing);
        return isZhangTing;
    }
}
